// pages/searchRes/searchRes.js
var app = getApp()
var baseUrl = app.globalData.baseUrl
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goods: null
  },

  async onLoad(options) {
    let keyWord = options.keyWord
    //查询数据库
    wx.request({
      url: baseUrl+'goods/search/'+keyWord,
      method: 'POST',
      success: res => {
        this.setData({
          goods: res.data
        })
      }
    })
  },

  toGoodsInfo(e){
    let goodsid = e.currentTarget.dataset.goodsid
    wx.navigateTo({
      url: '/pages/goods/goods?goodsid='+goodsid,
    })
  }

})